{% extends "servis/base.html" %}

{%block title %}
Nová zakázka
{%endblock %}

{%block scripts %}
u=0;
s=0;

$(document).ready(function () {
$("input#pridatSelectUkony").click(pridejSelectUkony);
$("input#pridatSelectSoubory").click(pridejSelectSoubory);
});
function pridejSelectUkony(){
	u = u+1;
	$("div#polozky").append("<p> <select name=\"" + u + "\">{% for p in ukony %} <option 	value='{{p.id}}'>{{p.nazev_ukonu}}</option> {%	endfor %} </select></p>"); 
	$("div#hid").html( "<input type=\"hidden\" name=\"pocetSelectuUkony\" value=\"" + u + "\"/><input type=\"hidden\"	name=\"pocetSelectuSoubory\" value=\"" + -1 + "\"/> ");
	$("input#pridatSelectSoubory").hide("slow");
	
}
 function pridejSelectSoubory(){
	s = s+1;
	$("div#polozky").append("<p> <select name=\"" + s + "\">{% for p in soubory %} <option 	value='{{p.id}}'>{{p.nazev}}</option> {%	endfor %} </select></p>"); 
	$("div#hid").html( "<input type=\"hidden\"	name=\"pocetSelectuUkony\" value=\"" + -1 + "\"/>	<input type=\"hidden\"	name=\"pocetSelectuSoubory\" value=\"" + s + "\"/> ");
	$("input#pridatSelectUkony").hide("slow");
	
}  
{%endblock %}

{%block content %}
		<h3>Nová zakázka</h3>
		<div id="zpravy"></div>
		<form action="/servis/zakazky/novy/pridat/"
		method="post" name="pridavaniZakazky" >
			<table>
				<tr>
					<td>Jméno zákazníka</td>
				       	<td>
							*</td><td><select
							name="zakaznik_id" >
							{% for z in zakaznici %}
								<option
								value="{{z.id}}">{{z.jmeno}}
								{{z.prijmeni}}</option>
							{% endfor %}
							</select>
					</td>
				</tr>
				

				<tr>
					<td >SPZ</td>
					<td>
					*</td><td><input type="text" value="{{spz}}" name="spz" />
					</td>
				</tr>
				<tr>
					<td style="vertical-align:top;">Popis</td>
					<td style="vertical-align:top;">
					*</td><td><textarea 
					value="{{popis}}" name="popis"
					cols="30" rows="6" ></textarea>
					</td>
				</tr>
			<tr>
			<td>		
			<input type="button" id="pridatSelectUkony"
			value="Přidej úkon" /></td>
			<td></td><td>
			<input type="button" id="pridatSelectSoubory"
			value="Přidej soubor oprav" />
	</td></tr>
			</table>
			<div id="polozky">	
		
			</div>
				<table>
				<tr>
					<td>* ~ povinné vyplnit</td>

				       	<td> 
						<input type="submit"
						value="Přidat zakázku"/>
					</td>
				</tr>
		</table>	
<div id="hid">
		<input type="hidden" name="pocetSelectuUkony" value="-1"/>
		<input type="hidden" name="pocetSelectuSoubory" value="-1"/>

</div>
	</form>



{%endblock content %}
